init_str = <<-EOS
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------


`timescale 1ns / 1ps

module system_tb;
   
   //Imputs
   reg [6:0] lat_inic;
   reg [6:0] lat_final;
   reg [6:0] long_inic;
   reg [6:0] long_final;
   
   //Istanciar DUT
   system dut (
               .lat_inic(lat_inic),
               .lat_final(lat_final),
               .long_inic(long_inic),
               .long_final(long_final)
	       );

   /* Simulation setup */ 
   initial begin 
      //set the file for loggin simulation data 
      $dumpfile("system_tb.vcd"); 
      //$monitor("%b,%b,%b",clk_tb,rst_tb,led_tb); 
      //export all signals in the simulation viewer 
      $dumpvars(-1, dut); 
      //$dumpvars(-1,clk_tb,rst_tb);
      #0      lat_inic <= 0;
      #0      lat_final <= 0;
      #0      long_inic <= 0;
      #0      long_final <= 0; 
EOS

end_str = <<-EOS
   end 
endmodule
EOS

File.open("system_tb.v", "w") { |f| 
      f.write(init_str);
      for i in 0..100
        f.write("\t\t#100\tlat_inic <= #{Random.rand(31)};\n")
        f.write("\t\t#0\tlat_final <= #{Random.rand(31)};\n")
        f.write("\t\t#0\tlong_inic <= #{Random.rand(31)};\n")
        f.write("\t\t#0\tlong_final <= #{Random.rand(31)};\n")
      end
      f.write(end_str)
      f.close
}
